<!-- 见证记录审核 -->
<template>
  <div class="layout-wrapper layout-witness">
    <div class="layout-header layout-search">
      <el-form :inline="true" :model="searchForm">
        <el-form-item label="行业类别">
          <el-cascader
            v-model="searchForm.industry"
            option-max-width="230px"
            class="ui-w230"
            :props="{ multiple: true }"
            collapse-tags
            :collapse-tags-max-num="1"
            :tooltip-max-width="230"
            tooltip-effect="light"
            :options="industryTypeAndIndustryData"
            clearable
            @change="industryChangeFn"
          />
        </el-form-item>
        <!-- {{ tenderModeOptionsObj }} -->
        <el-form-item label="交易方式">
          <el-select
            v-model="searchForm.tenderMode"
            class="ui-w180"
            option-max-width="180px"
            placeholder="请选择"
            clearable
            @change="tenderModeFn"
          >
            <el-option v-for="(label, key) in tenderModeOptionsObj" :key="key" :label="label" :value="key" />
          </el-select>
        </el-form-item>
        <!-- {{ zsTypeOptionsObj }} -->
        <el-form-item label="资审方式">
          <el-select
            v-model="searchForm.zsType"
            class="ui-w180"
            option-max-width="180px"
            placeholder="请选择"
            clearable
            @change="zsTypeFn"
          >
            <el-option v-for="(label, key) in zsTypeOptionsObj" :key="key" :label="label" :value="key" />
          </el-select>
        </el-form-item>
        <el-form-item label="开标时间">
          <el-date-picker
            v-model="searchForm.date"
            class="ui-w260"
            unlink-panels
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :clearable="true"
            value-format="yyyy-MM-dd"
            :picker-options="pickerOptions"
            @change="handleSearch()"
          />
        </el-form-item>
        <el-form-item>
          <el-input
            v-model.trim="searchForm.keywords"
            class="ui-w210"
            placeholder="项目/标段/名称/编号"
            @keyup.native.enter="handleSearch()"
          >
            <el-button slot="append" type="primary" icon="icon-sousuo" @click="handleSearch()" />
          </el-input>
        </el-form-item>
      </el-form>
    </div>
    <!-- <div class="layout-header ui-mb10">
      <el-button
        type="primary"
        icon="icon-sousuo"
        plain
        @click="handleBatchApprove()"
      >
        批量审核
      </el-button>
    </div> -->
    <div class="layout-body">
      <el-table
        v-loading="tableLoading"
        :data="tableList"
        style="width: 100%"
        height="100%"
        header-row-class-name="out-Table-header"
      >
        <el-table-column type="selection" width="35" align="right" />
        <el-table-column type="expand" width="30">
          <template slot-scope="scope">
            <el-table
              :data="scope.row.bidList"
              :merge-columns="mergeColumns"
              border
              style="width: 100%"
              row-class-name="in-Table"
              header-row-class-name="in-Table-header"
              :cell-class-name="handleCellClassName"
            >
              <el-table-column type="selection" width="53" align="center" />
              <el-table-column prop="bidSectionName" label="标段名称" min-width="223" />
              <el-table-column prop="bidSectionCode" label="标段编号" min-width="182" />
              <el-table-column prop="openStartTime" label="开标时间" min-width="148">
                <template slot-scope="bidScope">
                  {{ formatDateFn(bidScope.row.openStartTime, "yyyy-MM-dd HH:mm") }}
                </template>
              </el-table-column>
              <el-table-column prop="openAddress" label="开标室" min-width="120" />
              <el-table-column prop="evaluationAddress" label="评标室" min-width="120" />
              <el-table-column prop="witnessSubTaskName" label="见证阶段" min-width="90" show-overflow-tooltip />
              <el-table-column prop="witnessUserName" label="见证人" min-width="130" show-overflow-tooltip />
              <el-table-column prop="witnessStartTime" label="见证开始时间" min-width="148" show-overflow-tooltip>
                <template slot-scope="bidScope">
                  {{ formatDateFn(bidScope.row.witnessStartTime, "yyyy-MM-dd HH:mm") }}
                </template>
              </el-table-column>
              <el-table-column prop="witnessEndTime" label="见证结束时间" min-width="148" show-overflow-tooltip>
                <template slot-scope="bidScope">
                  {{ formatDateFn(bidScope.row.witnessEndTime, "yyyy-MM-dd HH:mm") }}
                </template>
              </el-table-column>
              <el-table-column prop="witnessResult" label="见证结果" min-width="120" show-overflow-tooltip>
                <template slot-scope="bidScope">
                  <div class="witness-result">
                    <i class="el-icon-warning-outline" />
                    异常({{ bidScope.row.witnessResult }})
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="操作" min-width="110">
                <template slot-scope="bidScope">
                  <el-button
                    v-if="bidScope.row.OPERATE_APPROVE_WITNESS_RECORD"
                    type="text"
                    @click="handleApprove(bidScope.row)"
                  >
                    审核见证记录
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column type="index" label="序号" width="53" align="center">
          <template slot-scope="scope">
            {{ (pageObj.currentPage - 1) * pageObj.pageSize + scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="projectName" label="项目名称" min-width="223" show-overflow-tooltip />
        <el-table-column prop="projectCode" label="项目编号" min-width="167" show-overflow-tooltip />
        <el-table-column
          prop="industry"
          label="行业类别"
          min-width="158"
          :formatter="formatterIndustry"
          show-overflow-tooltip
        />
        <el-table-column
          prop="tenderMode"
          label="交易方式"
          min-width="158"
          :formatter="formatterTenderMode"
          show-overflow-tooltip
        />
        <el-table-column
          prop="qualificationExamMethod"
          label="资审方式"
          min-width="159"
          :formatter="formatterQualificationExamMethod"
          show-overflow-tooltip
        />
        <el-table-column prop="businessUnit" label="业务部门" min-width="159" show-overflow-tooltip />
        <el-table-column prop="operateUserName" label="经办人" min-width="159" show-overflow-tooltip />
        <el-table-column label="操作" min-width="160">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.OPERATE_PROJECT_DETAIL"
              type="text"
              @click="handleViewDetailFn(scope.row.projectId)"
            >
              项目详情
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="layout-footer">
      <pagination
        v-if="pageObj.total > pageObj.pageSizes[0]"
        :total="pageObj.total"
        :page.sync="pageObj.currentPage"
        :limit.sync="pageObj.pageSize"
        :page-sizes="pageObj.pageSizes"
        @pagination="approveListFn()"
      />
    </div>
    <!-- 项目详情弹窗 -->
    <!-- <ProjectDetailsDialog :visible.sync="detailDialogShow" :projectId="currentProjectId" :taskObj="TASKOBJ" /> -->
    <ProjectDetailsDrawer
      :visible.sync="detailDialogShow"
      @closeDrawer="closeDrawerFn"
      :project-id="currentProjectId"
      :task-obj="TASKOBJ"
    />
  </div>
</template>
<script>
  // 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
  import { moduleInit, approveList, witnessProjectBidSectionDetail } from "../../../../api/api";
  import { FindArrayFn, getFirstAndSecondLevel, formatDateFn } from "../../../../utils/utils";
  import ProjectDetailsDrawer from "../../../../components/dialog/ProjectDetailsDrawer.vue";
  export default {
    // 引入组件
    components: { ProjectDetailsDrawer },
    props: {},
    data() {
      // 这里存放数据
      return {
        searchForm: {
          industry: [],
          industrySecondLevel: [], // 选中的行业类别的二级菜单的数组集合
          tenderMode: "",
          zsType: "",
          date: [],
          keywords: ""
        },
        TASKOBJ: {}, // 后端返回的所有下拉映射值数据
        tenderModeIndustryObj: {}, // 依据行业类别一级菜单分组显示的交易方式
        industryTypeAndIndustryData: [], // 行业类别
        tenderModeOptionsObj: {}, // 交易方式下拉
        zsTypeOptionsObj: {}, // 资审方式
        pickerOptions: {
          shortcuts: [
            {
              text: "最近一周",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit("pick", [start, end]);
              }
            },
            {
              text: "最近一个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                picker.$emit("pick", [start, end]);
              }
            },
            {
              text: "最近三个月",
              onClick(picker) {
                const end = new Date();
                const start = new Date();
                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                picker.$emit("pick", [start, end]);
              }
            }
          ]
        },
        tableList: [],
        tableLoading: true,
        mergeColumns: [
          {
            key: "bidSectionName",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "bidSectionCode",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "openStartTime",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "openAddress",
            conditions: ["bidSectionName", "bidSectionCode"]
          },
          {
            key: "evaluationAddress",
            conditions: ["bidSectionName", "bidSectionCode"]
          }
        ],
        pageObj: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          pageSizes: [10, 20, 30]
        },
        pathUrl: false, // router
        detailDialogShow: false, // 是否展示项目详情弹窗
        currentProjectId: "" // 当前操作的项目id
      };
    },
    // 监听属性 类似于data概念
    computed: {
      wsData() {
        console.log("this.$websocket.getters.wsData", this.$websocket.getters.wsData);
        // return this.$websocket.getters.wsData;
        return this.$websocketNetty.getters.wsData;
      }
    },
    // 监控data中的数据变化
    watch: {
      wsData(val) {
        console.log("watch wsData", val);
        if (val) {
          this.witnessProjectBidSectionDetailFn(val);
        }
      }
    },
    // 生命周期 - 创建完成（可以访问当前this实例）
    created() {
      this.searchForm.date = [
        this.$moment(new Date()).format("yyyy-MM-DD"),
        this.$moment(new Date()).format("yyyy-MM-DD")
      ];
      this.cacheInitDataFn();
      this.pageInitFn();
    },
    // 生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {},
    // 生命周期 - 销毁之前
    beforeDestroy() {},
    // 生命周期 - 销毁完成
    destroyed() {},
    // 如果页面有keep-alive缓存功能，这个函数会触发
    activated() {
      console.log("activated");
      this.cacheInitDataFn();
      // 列表重新渲染
      this.approveListFn();
      // this.approveListFn();
    },
    beforeRouteLeave(to, from, next) {
      to.meta.keepAlive = true;
      next();
    },
    beforeRouteEnter(to, from, next) {
      next((vm) => {
        console.log(to);
        console.log(from);
        // vm.pathUrl = from.fullPath;
        vm.pathUrl = from.name;
      });
    },
    // 方法集合
    methods: {
      ...{ formatDateFn },
      pageInitFn() {
        clearTimeout(this.timeFlag);
        this.timeFlag = setTimeout(() => {
          this.moduleInitFn();
        }, 300);
      },
      cacheInitDataFn() {
        const arr = [
          "ViewingWitnessRecords",
          "AddWitnessTask",
          "WitnessRecordApprove",
          "Attachment",
          "ViewingWitnessData"
        ];
        if (arr.indexOf(this.pathUrl) > -1 || this.pathUrl === null) {
          this.searchForm = JSON.parse(sessionStorage.getItem("searchForm"));
          this.pageObj.currentPage = Number(sessionStorage.getItem("currentPage"));
          this.pageObj.pageSize = Number(sessionStorage.getItem("pageSize"));
        }
      },
      searchInitDataFn() {
        this.industryTypeAndIndustryData = JSON.parse(JSON.stringify(this.TASKOBJ.industryTypeAndIndustry));
        this.TASKOBJ.industryTypeAndIndustry.forEach((item) => {
          item.BIDDING = {};
          item.children.forEach((itemB) => {
            itemB.childrenTenderMode.forEach((itemC) => {
              console.log("itemC", itemC.value);
              item.BIDDING[itemC.value] = itemC.label;
              // 交易方式
              if (!this.tenderModeOptionsObj[itemC.value]) {
                this.tenderModeOptionsObj[itemC.value] = itemC.label;
              }
              // 资审方式
              itemC.children.forEach((itemD) => {
                console.log("itemD", itemD.value);
                if (!this.zsTypeOptionsObj[itemD.value]) {
                  this.zsTypeOptionsObj[itemD.value] = itemD.label;
                }
              });
            });
          });
        });
      },
      async moduleInitFn() {
        console.log("moduleInitFn");
        try {
          const res = await moduleInit({ moduleName: "CREATETASK" });
          // const res = await moduleInit({ moduleName: "TASK" });
          if (res.success) {
            this.TASKOBJ = res.data;
            this.TASKOBJ.industryTypeAndIndustry.forEach((item) => {
              item.children.forEach((itemB) => {
                // children会在菜单中显示1
                if (itemB.children) {
                  itemB.childrenTenderMode = JSON.parse(JSON.stringify(itemB.children));
                  itemB.children = null;
                } else {
                  itemB.childrenTenderMode = JSON.parse(JSON.stringify(itemB.childrenIndustry));
                }
              });
            });
            this.searchInitDataFn();
            // 依据行业类别的一级分类分组显示交易方式
            // for (let i = 0; i < res.data.industryTypeAndTenderMode.length; i++) {
            //   const obj = res.data.industryTypeAndTenderMode[i];
            //   this.tenderModeIndustryObj[obj.value] = obj.children;
            // }
            setTimeout(() => {
              this.industryChangeFn([]); // 获取交易方式的下拉及获取列表数据
            }, 300);
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (error) {
          console.error(error);
          this.tableLoading = false;
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 行业类别发生变化，交易方式下拉选项联动
      tenderModeFn(val) {
        console.log("val", val);
        // 这里是反选代码 by link 20220720
        // this.industryTypeAndIndustryData = [];
        // // this.industryTypeAndIndustryData = JSON.parse(JSON.stringify(this.TASKOBJ.industryTypeAndIndustry));
        // this.TASKOBJ.industryTypeAndIndustry.forEach((itemA) => {
        //   console.log("itemA", itemA);
        //   const tempArr = [];
        //   const tempItemDObj = {};
        //   itemA.children.forEach((itemB) => {
        //     console.log("itemB", itemB);
        //     if (itemB.childrenTenderMode.some((itemC) => itemC.value === val || val === "")) {
        //       tempArr.push(itemB);
        //     }
        //     itemB.childrenTenderMode.forEach((itemD) => {
        //       if (val === itemD.value || val === "") {
        //         itemD.children.forEach((itemE) => {
        //           tempItemDObj[itemE.value] = itemE.label;
        //         });
        //       }
        //     });
        //   });
        //   console.log("tempArr", tempArr);
        //   this.zsTypeOptionsObj = JSON.parse(JSON.stringify(tempItemDObj));
        //   if (tempArr.length) {
        //     const tempItemA = JSON.parse(JSON.stringify(itemA));
        //     tempItemA.children = tempArr;
        //     this.industryTypeAndIndustryData.push(tempItemA);
        //   }
        // });
        console.log("this.industryTypeAndIndustryData", this.industryTypeAndIndustryData);
        this.handleSearch();
      },
      zsTypeFn(val) {
        console.log("val", val);
        // 这里是反选代码 by link 20220720
        // this.industryTypeAndIndustryData = [];
        // this.TASKOBJ.industryTypeAndIndustry.forEach((itemA) => {
        //   console.log("itemA", itemA);
        //   const tempArr = [];
        //   const tempItemDObj = {};
        //   itemA.children.forEach((itemB) => {
        //     console.log("itemB", itemB);
        //     // if (itemB.childrenTenderMode.some((itemC) => itemC.value === val || val === "")) {
        //     //   tempArr.push(itemB);
        //     // }
        //     itemB.childrenTenderMode.forEach((itemD) => {
        //       itemD.children.forEach((itemE) => {
        //         if (val === itemE.value || val === "") {
        //           tempItemDObj[itemD.value] = itemD.label;
        //           tempArr.push(itemB);
        //         }
        //       });
        //     });
        //   });
        //   console.log("tempArr", tempArr);
        //   // this.zsTypeOptionsObj = JSON.parse(JSON.stringify(tempItemDObj));
        //   this.tenderModeOptionsObj = JSON.parse(JSON.stringify(tempItemDObj));
        //   if (tempArr.length) {
        //     const tempItemA = JSON.parse(JSON.stringify(itemA));
        //     tempItemA.children = tempArr;
        //     this.industryTypeAndIndustryData.push(tempItemA);
        //   }
        // });
        this.handleSearch();
      },
      industryChangeFn(arr) {
        console.log("arr", arr);
        const obj = getFirstAndSecondLevel(arr);
        this.searchForm.industrySecondLevel = obj.secondLevel;
        console.log("this.searchForm.industrySecondLevel", this.searchForm.industrySecondLevel);
        // 等一下在写，清空的逻辑
        // if (arr.length===0) {
        // }
        // 这里是反选代码 by link 20220720
        // this.tenderModeOptionsObj = {};
        // this.TASKOBJ.industryTypeAndIndustry.forEach((itemA) => {
        //   console.log("itemA", itemA);
        //   const tempArr = [];
        //   const tempItemDObj = {};
        //   const tempItemEObj = {};
        //   itemA.children.forEach((itemB) => {
        //     console.log("itemB", itemB);
        //     if (this.searchForm.industrySecondLevel.some((itemC) => itemC === itemB.value) || !arr.length) {
        //       itemB.childrenIndustry.forEach((itemD) => {
        //         tempItemDObj[itemD.value] = itemD.label;
        //         itemD.children.forEach((itemE) => {
        //           tempItemEObj[itemE.value] = itemE.label;
        //         });
        //       });
        //     }
        //   });
        //   console.log("tempArr", tempArr);
        //   this.zsTypeOptionsObj = JSON.parse(JSON.stringify(tempItemEObj));
        //   this.tenderModeOptionsObj = JSON.parse(JSON.stringify(tempItemDObj));
        //   // if (tempArr.length) {
        //   //   const tempItemA = JSON.parse(JSON.stringify(itemA));
        //   //   tempItemA.children = tempArr;
        //   //   this.industryTypeAndIndustryData.push(tempItemA);
        //   // }
        // });
        if (this.$route.query.urlName === "WITNESS_RECORD_APPROVE") {
          this.approveListFn();
          this.$route.query.urlName = "";
        } else {
          this.handleSearch();
        }
      },
      getTenderModeOptions(obj, arr) {
        for (let i = 0; i < arr.length; i++) {
          // var hasBarProperty = Object.prototype.hasOwnProperty.call(obj, arr[i].value);
          // if (!hasBarProperty) {
          // eslint-disable-next-line no-prototype-builtins
          if (!obj.hasOwnProperty(arr[i].value)) {
            obj[arr[i].value] = arr[i].label;
          }
        }
        return obj;
      },
      // 搜索查询
      handleSearch() {
        this.pageObj.total = 0;
        this.pageObj.currentPage = 1;
        this.approveListFn();
      },
      // 见证审核记录列表查询
      async approveListFn() {
        clearTimeout(this.apiflag);
        this.apiflag = setTimeout(() => {
          this.approveList2Fn();
        }, 500);
      },
      async approveList2Fn() {
        const form = JSON.stringify(this.searchForm);
        sessionStorage.setItem("searchForm", form);
        sessionStorage.setItem("currentPage", this.pageObj.currentPage);
        sessionStorage.setItem("pageSize", this.pageObj.pageSize);
        try {
          this.tableLoading = true;
          this.tableList = [];
          const params = {
            industryList: this.searchForm.industrySecondLevel,
            tenderMode: this.searchForm.tenderMode,
            qualificationExamMethod: this.searchForm.zsType,
            search: this.searchForm.keywords,
            currentPage: this.pageObj.currentPage,
            pageSize: this.pageObj.pageSize
          };
          if (this.searchForm.date && this.searchForm.date.length) {
            params.startTime = `${this.searchForm.date[0]} 00:00:00`;
            params.endTime = `${this.searchForm.date[1]} 23:59:59`;
          }
          const res = await approveList(params);
          this.tableLoading = false;
          if (res.success) {
            if (res.data.result.length === 0 && this.pageObj.currentPage > 1) {
              this.pageObj.currentPage--;
              this.approveList2Fn();
              return;
            }
            const arr = [];
            res.data.result.forEach((proItem) => {
              const proObj = proItem.data;
              const { projectId } = proItem.data;
              proItem.pageOpers.forEach((val) => {
                proObj[val.code] = true;
              });
              proObj.bidList = [];
              proItem.data.bidSectionVOList.forEach((bidItem) => {
                const bidObj = this.$cafeUtils.deepClone(bidItem);
                this.$delete(bidObj, "witnessSubTaskVOList");
                let newBidObj = {};
                bidItem.witnessSubTaskVOList.result.forEach((witnessItem, index) => {
                  newBidObj = { projectId, ...bidObj, ...witnessItem.data };
                  witnessItem.pageOpers.forEach((val) => {
                    newBidObj[val.code] = true;
                  });
                  // 判断标段表格框是否变细，除了第一个均变细
                  if (index < bidItem.witnessSubTaskVOList.result.length - 1) {
                    newBidObj.thinBorder = true;
                  }
                  proObj.bidList.push(newBidObj);
                });
              });
              arr.push(proObj);
            });
            this.tableList = arr;
            this.pageObj.total = res.data.pageBean.count;
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (error) {
          console.error(error);
          this.tableLoading = false;
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 设置表格单元格样式
      handleCellClassName({ row, columnIndex }) {
        // 由于第2、3、4、5、6列进行了单元格合并，使用的是当前标段第一行的border，故不需要变细
        let className = "";
        if (
          row.thinBorder &&
          columnIndex !== 1 &&
          columnIndex !== 2 &&
          columnIndex !== 3 &&
          columnIndex !== 4 &&
          columnIndex !== 5
        ) {
          className = "in-Table-cell";
        }
        return className;
      },
      formatterIndustry(row) {
        let str = "";
        if (row.industryType) {
          const obj = FindArrayFn(this.TASKOBJ.industryTypeAndIndustry, row.industryType);
          str = obj.label;
        }
        if (row.industry) {
          const inObj = FindArrayFn(this.TASKOBJ.industryTypeAndIndustry, row.industry);
          str = `${str}/${inObj.label}`;
        }
        return str;
      },
      formatterTenderMode(row) {
        let str = "";
        if (row.tenderMode) {
          str = this.tenderModeOptionsObj[row.tenderMode];
        }
        return str;
      },
      formatterQualificationExamMethod(row) {
        let str = "";
        if (row.qualificationExamMethod) {
          const obj = FindArrayFn(this.TASKOBJ.qualificationExamMethods, row.qualificationExamMethod);
          str = obj.label;
        }
        return str;
      },
      closeDrawerFn() {
        console.log("closeDrawerFn");
        this.currentProjectId = "";
        this.detailDialogShow = false;
      },
      // 项目详情
      handleViewDetailFn(projectId) {
        this.currentProjectId = projectId;
        this.detailDialogShow = true;
      },
      // 审核见证记录
      handleApprove(row) {
        this.$router.push({
          name: "ViewingWitnessRecords",
          query: {
            projectId: row.projectId,
            bidSectionId: row.bidSectionId,
            witnessLinkCode: row.witnessLinkCode,
            witnessSubTaskName: row.witnessSubTaskName,
            witnessSubTaskId: row.witnessSubTaskId,
            witnessSubTaskStatusEnum: "WITNESS_UN_REVIEWED",
            urlName: "WitnessRecordApprove"
          }
        });
      },
      // 批量审核
      handleBatchApprove() {
        return this.$message({
          type: "warning",
          message: "功能待开发"
        });
      },
      // 见证详细
      async witnessProjectBidSectionDetailFn(data) {
        // this.tableLoading = true;
        // this.tableData = [];
        console.log("data", data);
        if (!data || !data.projectId) {
          return;
        }
        const p = {
          projectId: data.projectId,
          bidSectionIdList: data.bidSectionIdList
        };
        console.log("p", p);
        try {
          const res = await witnessProjectBidSectionDetail(p);
          console.log("res", res);
          if (res.success) {
            // let i, j;
            this.tableList.forEach((item) => {
              if (item.projectId === data.projectId) {
                // i = index;
                // 项目名称 , 项目编号,行业类别,交易方式,资审方式
                console.log("item", item);
                // .bidSectionInfoList,witnessProjectBaseInfo
                // item.projectName = res.data;
                const project = res.data.witnessProjectBaseInfo;
                const { bidSectionInfoList } = res.data;
                item.projectName = project.projectName;
                item.projectCode = project.projectCode;
                item.industry = project.industry;
                item.industryType = project.industryType;
                item.tenderMode = project.tenderMode; // 交易方式
                item.businessUnit = project.businessUnit;
                item.operateUserName = project.operateUserName;
                // item.sourceSystemCode = project.sourceSystemCode;
                // item.sourceSystemName = project.sourceSystemName;
                item.qualificationExamMethod = project.qualificationExamMethod; // 资审方式
                bidSectionInfoList.forEach((itemC) => {
                  // table的数据
                  item.bidList.forEach((itemB) => {
                    const flag = itemC.bidSectionCode === itemB.bidSectionCode;
                    if (flag) {
                      itemB.evaluationAddress = itemC.evaluationAddress;
                      itemB.openAddress = itemC.openAddress;
                      itemB.openStartTime = itemC.openStartTime;
                      itemB.bidSectionName = itemC.bidSectionName;
                      itemB.bidSectionCode = itemC.bidSectionCode;
                      // itemB.witnessAllocateUserName =
                      itemC.witnessSubTaskVOList.forEach((itemD) => {
                        if (itemD.witnessSubTaskName === itemB.witnessSubTaskName) {
                          console.log("1111", itemD.witnessSubTaskName);
                          itemB.witnessAllocateUserName = itemD.witnessAllocateUserName;
                          itemB.witnessUserName = itemD.witnessUserName;
                          itemB.witnessSubTaskAllocateTime = itemD.witnessSubTaskAllocateTime;
                        }
                      });
                    }
                  });
                });
              }
            });
            this.tableData;
            // this.$set(this.tableData, i, Obj);
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (error) {
          console.warn(error);
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .witness-result {
    width: 76px;
    height: 20px;
    line-height: 20px;
    background: #fc9306;
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    text-align: center;
  }
</style>
